package guda.shop.cms.manager.impl;

import guda.shop.cms.dao.StandardTypeDao;
import guda.shop.cms.entity.StandardType;
import guda.shop.cms.manager.StandardTypeMng;
import guda.shop.common.hibernate3.Updater;
import guda.shop.common.page.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StandardTypeMngImpl
        implements StandardTypeMng {
    private StandardTypeDao standardTypeDao;

    @Transactional(readOnly = true)
    public Pagination getPage(int paramInt1, int paramInt2) {
        Pagination localPagination = this.standardTypeDao.getPage(paramInt1, paramInt2);
        return localPagination;
    }

    public StandardType getByField(String paramString) {
        return this.standardTypeDao.getByField(paramString);
    }

    @Transactional(readOnly = true)
    public StandardType findById(Long paramLong) {
        StandardType localStandardType = this.standardTypeDao.findById(paramLong);
        return localStandardType;
    }

    public List<StandardType> getList() {
        return this.standardTypeDao.getList();
    }

    public List<StandardType> getList(Long paramLong) {
        return this.standardTypeDao.getList(paramLong);
    }

    public StandardType save(StandardType paramStandardType) {
        paramStandardType = this.standardTypeDao.save(paramStandardType);
        return paramStandardType;
    }

    public StandardType update(StandardType paramStandardType) {
        Updater localUpdater = new Updater(paramStandardType);
        StandardType localStandardType = this.standardTypeDao.updateByUpdater(localUpdater);
        return localStandardType;
    }

    public StandardType deleteById(Long paramLong) {
        StandardType localStandardType = this.standardTypeDao.deleteById(paramLong);
        return localStandardType;
    }

    public StandardType[] deleteByIds(Long[] paramArrayOfLong) {
        StandardType[] arrayOfStandardType = new StandardType[paramArrayOfLong.length];
        int i = 0;
        int j = paramArrayOfLong.length;
        while (i < j) {
            arrayOfStandardType[i] = deleteById(paramArrayOfLong[i]);
            i++;
        }
        return arrayOfStandardType;
    }

    public StandardType[] updatePriority(Long[] paramArrayOfLong, Integer[] paramArrayOfInteger) {
        int i = paramArrayOfLong.length;
        StandardType[] arrayOfStandardType = new StandardType[i];
        for (int j = 0; j < i; j++) {
            arrayOfStandardType[j] = findById(paramArrayOfLong[j]);
            arrayOfStandardType[j].setPriority(paramArrayOfInteger[j]);
        }
        return arrayOfStandardType;
    }

    @Autowired
    public void setDao(StandardTypeDao paramStandardTypeDao) {
        this.standardTypeDao = paramStandardTypeDao;
    }
}

